#include "stdio.h"
#include "string.h"
#include "math.h"
#include "stdlib.h"

int record[11][11],temp[11][11];

int getvalue(int *tt)
{
    int i,j,tot; 
    tot=0;    // get the shu
    j=1;
    for (i=tt[0];i>=1;i--) 
    {
        tot+=tt[i]*j;
        j*=10;
    }
    return tot;
}    

void movetemp(int len)
{
 	memcpy(record,temp,sizeof(temp));   
	record[0][0]=len;
} 

int xiao(int *t1,int *t2)  // xiao for 1 ,equal for 0 large for -1
{
    int i,j;
    
    if (t1[0]<t2[0]) return 1;
    if (t1[0]>t2[0]) return -1;
    if (t1[0]==t2[0])
        for (i=1;i<=t1[0];i++)
        	if (t1[i]!=t2[i])
    		{
    		    if (t1[i]<t2[i]) return 1;
    		    else return -1;
    		    break;
    		}    
	return 0;
}    


void dfs(int *shu,int site)
{
    int i, j, tot, now, flag=0;
    int tt[11], tq[11], bak[11], p, end;
    
    for (i=1;i<=shu[0];i++) temp[site][i]=shu[i];   //record
    temp[site][0]=shu[0];
        
    tot=getvalue(shu);
//    printf("the shu is :%d\n",tot);

//	printf("xiao is : %d\n",xiao(tt,tq));
    
	if (tot==0||tot<10)
	{
	    if (site>record[0][0])
	    {
	        movetemp(site);
	    }
	    else if (site==record[0][0])
      	{
       	 
      	    for (i=1;i<=site;i++)
      	    {
      	        j=xiao(temp[i],record[i]);
      	        if (j!=0)
      	        {
          	    	if ( j==1 )   movetemp(site);
          	    	break;    
      	 		}   	
  	 		}   	
        }	 
	}   
 	else if (site+shu[0]>record[0][0])   // ·&Ouml;&Ouml;§&para;¨&frac12;&ccedil; 
  	{
  	    memset(tt,0,sizeof(tt));
  	    now=0;
  	    p=1;
  	    end=shu[0];
  	    tt[p]=0;
   
  	    while (p>0)
  	    {
  	        tt[p]++;
  	      
  	        if (p>=end)
  	        {
  	            p--;
        	    now/=10;
  	    	}   
        	else if (tt[p]>end)
        	{
        	    p--;
        	    now/=10;
        	}
         	else if (!(p==1&&shu[tt[1]]==0))  // forbid head is 0 ,
          	{
          	    
          	    now=now*10+shu[tt[p]];
          	    if (tot%now==0&&now>1) 
          	    {
          	        flag=1;
          	        tq[0]=0;
          	        for (i=0;i<=10;i++) bak[i]=shu[i];
          	        for (i=1;i<=p;i++) bak[tt[i]]=-1;
          	        for (i=1;i<=shu[0];i++)
          	        	if (shu[i]==bak[i])
          	        	{
          	        	    tq[0]++;
          	        	    tq[tq[0]]=shu[i];
          	        	}    
      	        	while (tq[1]==0&&tq[0]>1)
                	{
                	  for (i=1;i<tq[0];i++)  tq[i]=tq[i+1];
                      tq[0]--;
                  	}    
      	        	dfs(tq,site+1);
          	    }
               	p++;
                tt[p]=tt[p-1];    
          	}    
  	    }   // end of search 
  	    if (!flag)
  	    {
      	    if (site>record[0][0])
       	    {
    	        movetemp(site);
    	    }
    	    else if (site==record[0][0])
          	{
           	 
          	    for (i=1;i<=site;i++)
          	    {
          	        j=xiao(temp[i],record[i]);
          	        if (j!=0)
          	        {
              	    	if ( j==1 )   movetemp(site);
              	    	break;    
          	 		}   	
      	 		}   	
            }	 
  	        
  	    }    
  	}     
}



main()
{
    int indata,i,j,k;
    int shu[11];

	while (1)
	{
	    scanf("%d", &indata);
	   
	    if (indata==0) break;
	    printf("%d",indata);  
        memset(shu,0,sizeof(shu));
	    memset(record,0,sizeof(record));
	    memset(temp,0,sizeof(temp));
		while (indata!=0)
  		{
  		    shu[0]++;
  		    shu[shu[0]]=indata%10;
  		    indata/=10;
    	}    	
//		for (i=1;i<=shu[0];i++) printf("%d ",shu[i]); printf("\n");
     	j=shu[0]/2;         //swap order
     	for (i=1;i<=j;i++) 
    	{
    	    k=shu[i];
         	shu[i]=shu[shu[0]-i+1];	
          	shu[shu[0]-i+1]=k;
    	}    
//    	for (i=1;i<=shu[0];i++) printf("%d ",shu[i]); printf("\n");

		dfs(shu,1);
		if (record[0][0])
		{
    		for (i=2;i<=record[0][0];i++) 
    		{
		    	printf(" ");
    			for (j=1;j<=record[i][0];j++) printf("%d",record[i][j]);
    		}		
		}		
		printf("\n");
	}    
    return 0;
}    
